package com.wlk.controller;

import com.wlk.pojo.Department;
import com.wlk.pojo.dto.DepartmentDTO;
import com.wlk.service.DepartmentService;
import com.wlk.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
    @RequestMapping("/department")
public class DepartmentController {
    @Resource
    private DepartmentService departmentService;

    /**
     * @description: 新增部门
     * @author:
     * @date: 2024/6/13 下午5:45
     * @param:
     * @return:
     **/
    @PostMapping("/add")
    public Result addDepartment(@RequestBody DepartmentDTO departmentDTO){
        return departmentService.addDepartment(departmentDTO);
    }

    /**
     * @description: 删除部门
     * @author:
     * @date: 2024/6/14 上午9:30
     * @param:
     * @return:
     **/
    @DeleteMapping("/delete/{depCode}")
    public Result delDep(@PathVariable("depCode") String depCode){
        return departmentService.deleteDepartment(depCode);
    }

    /**
     * @description: 更新部门信息
     * @author:
     * @date: 2024/6/14 上午9:32
     * @param:
     * @return:
     **/
    @PutMapping("/update")
    public Result updateDepartment(@RequestBody Department department){
        return departmentService.updateDepartment(department);
    }

    /**
     * @description: 供项目模块调用下拉列表
     * @author:
     * @date: 2024/6/14 上午11:16
     * @param:
     * @return:
     **/
    @GetMapping("/getDepListForPro")
    public Result getDepListForPro(){
        return departmentService.getDepListForPro();
    }

    /**
     * @description: 部门列表
     * @author:
     * @date: 2024/6/14 下午5:28
     * @param:
     * @return:
     **/
    @GetMapping("/list")
    public Result getDepList(){
        return departmentService.getDepUserList();
    }





}
